#ifndef MYTCPSERVER_H
#define MYTCPSERVER_H

#include <QTcpServer>
class QThread;
class MyTcpServer : public QTcpServer
{
    Q_OBJECT
public:
    enum ServerType{
        DeviceServer,
        UserServer
    };
    explicit MyTcpServer(ServerType type, QObject *parent = nullptr);
    /**
     * @brief 停止服务器，并断开所有连接
     */
    void serverCloseAndClear();

signals:
    void abortAllClient();
    void dataSendSig(const QByteArray &data);
    void dataReceiveSig(const QByteArray &data);

protected slots:
    void socketDisconnectedSlot();

protected:
    void incomingConnection(qintptr socketDescriptor);
    void autoFreeThread();

    QList<QThread *> thList;
    ServerType serverType;

};

#endif // MYTCPSERVER_H
